<template>
    <div>
        <van-nav-bar
                title="设置"
                left-text="返回"
                left-arrow
                @click-left="onClickLeft"

        />

        <van-cell-group inset>
            <van-cell title="账号资料" is-link @click="form"/>


            <van-popup
                    round
                    v-model:show="show"
                    position="bottom"
                    :style="{ height: '30%' }"
                    closeable

            />
            <van-cell title="收货地址" is-link/>
            <van-cell title="退出登录" is-link @click="onalert"/>

        </van-cell-group>

    </div>
</template>

<script>
    import {Toast} from 'vant';
    import {ref} from 'vue';
    import {Dialog} from 'vant';

    export default {


        setup() {
            const show = ref(false);
            const onClickLeft = () => Toast('返回');
            return {
                show,
                onClickLeft,
            };
        },
        methods: {
            onClickLeft() {
                this.$router.push("/MY")
            },
            form() {
                this.$router.push("MyForm")
            },
            onalert() {
                Dialog.confirm({
                    title: '标题',
                    message: '弹窗内容',
                })
                    .then(() => {
                        // on confirm
                        var that=this
                        this.axios.get("http://localhost:8080/api/user/loginout.do",{headers: {"usertoken": this.$store.state.token}}).then(function (res) {
                            if (res.data.code == 10000) {
                                let path = that.$route.query.redirect
                                that.$router.replace(path == '/' || path == undefined ? '/my' : path)
                            } else {
                                that.$toast("退出登录失败")
                            }
                                })
                    })
                    .catch(() => {
                        // on cancel
                    });
            }
        }
    };
</script>

<style scoped>

</style>